#include "VC110.h"
#include "PortUtility.h"

namespace LineDisplayImp
{
	using namespace PortUtility;

	CLD_VC110::CLD_VC110()
	{
	}

	CLD_VC110::~CLD_VC110()
	{
	}

	void CLD_VC110::Initialize()
	{
		PR_SendStr2Com(m_portInfo.hCom, "\x1b\x40",2, m_portInfo.oWrite);
	}

	void CLD_VC110::ClearDescriptors()
	{
		PR_SendStr2Com(m_portInfo.hCom, "\x1b\x73",2, m_portInfo.oWrite);
	}

	void CLD_VC110::ClearText()
	{
		PR_SendStr2Com(m_portInfo.hCom, L"\x0c", 1, m_portInfo.oWrite );
	}

	void CLD_VC110::DisplayText(wstring strData, int nAttribute)
	{
		/*
		SendStringEx("\x1b\x51\x41",3);
		SendStringEx(pszText, 10);
		SendStringEx("\x0d",1);
		*/

		string strText = wstring2string(strData);
		PR_SendStr2Com(m_portInfo.hCom, "\x1b\x51\x41",3, m_portInfo.oWrite);
		PR_SendStr2Com(m_portInfo.hCom, (char*)strText.c_str(), strText.length(), m_portInfo.oWrite);

		PR_SendStr2Com(m_portInfo.hCom, "\x0d", 1, m_portInfo.oWrite);
	}

	void CLD_VC110::SetDescriptor(int nDescriptor, int nAttribute)
	{
		/*
		char szText[4];
		memset(szText, '\0',4);
		sprintf(szText,"\x1b\x73%c", nFlag);
		return SendStringEx(szText, 3);
		*/
		char szCmd[4];
		memset(szCmd, '\0',4);
		sprintf(szCmd,"\x1b\x73%c", nDescriptor);

		PR_SendStr2Com(m_portInfo.hCom, (char*)szCmd, 3, m_portInfo.oWrite);
	}
}